package hemowork_8_29;

import java.io.*;

public class Test02 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        String path = "src/main/java/hemowork_8_29/";
        File file = new File(path+"." );
        ObjectInputStream ois = null;

        //创建文件列表
        File[] files = file.listFiles(file1 ->file1.getName().endsWith(".obj"));
        User user = new User();
        for (int i = 0;i < files.length;i ++){
            //获取obj文件
            FileInputStream fis = new FileInputStream(files[i]);
            ois = new ObjectInputStream(fis);
            //读取
            Object obj = ois.readObject();
            if(obj instanceof User ){
                user = (User) obj;
            }
        }
        System.out.println(user);
        ois.close();

    }
}
